fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

file

io.file

file -- a unit type that contains effects related to file I/O

Constructors

Delete ref:effect is[Contains abstract features][src]
Delete -- effect wrapping the file delete operation
file_mutate:mutate is[Private constructor][src]
the mutate effect that is used
for reading/writing to file
L_Stat ref:effect is[Contains abstract features][src]
L_Stat -- effect providing operations to retrieve file stats
mapped_buffer:Buffer u8, io.file.mapped_buffer.this,mutate is[Private constructor][src]
mapped buffer gives access to the memory region a file is mapped
to via `mmap`.
meta_data(path io.this.path,sz i64,atime i64,mtime i64,ctime i64,is_regular bool,is_dir bool,is_link bool,uid i64,gid i64):Any is[src]
meta_data will be a feature storing the metadata of file/dir
mode:Any is[src]
the mode to use when opening a file
Move ref:effect is[Contains abstract features][src]
Move -- effect wrapping the file move operation
open:effect is[Private constructor][src]
effect for manipulating open files
Seek ref:effect is[Contains abstract features][src]
Seek -- effect providing stream seeking operations
Stat ref:effect is[Contains abstract features][src]
Stat -- effect providing operations to retrieve file stats

Functions

append(p io.path,a Any) => outcome unit[src]
append `a`.as_string to file `f`
as_string => String[Inherited from  Any][src]
create a String from this instance. Unless redefined, `a.as_string` will
create `"instance[T]"` where `T` is the dynamic type of `a`
delete(path io.path) => outcome unit[src]
shorthand for accessing Delete effect in current environment and performing the default delete operation using io.file.Delete.delete path
deletes the file/dir found in the path
returns unit as outcome in case of successful deletion and error in case of failure
if the targeted dir has content, then the return value will be error and the deletion will not take place
dynamic_apply(R:Any,F:Typed_Function R,f F) => R[Inherited from  Any][src]
dynamic_apply -- apply `f.call` to `Any.this`'s dynamic type and value

This can be used to perform operation on values depending on their dynamic
type.

Here is an example that takes a `Sequence Any` that may contain boxed values
of types `i32` and `f64`. We can now write a feature `get_f64` that extracts
these values converted to `f64` and build a function `sum` that sums them up
as follows:


dynamic_type => Type[Inherited from  Any][src]
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.

There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
exists(path io.path) => bool[src]
Does a file or directory at path exist?
move(old io.path,new io.path) => outcome unit[src]
shorthand for accessing Move effect in current environment and performing the default move operation using
io.file.Move.move old new
moves file/dir from an old path to a the new path
can rename the file/dir as well by changing the name of the old file/dir to a new name in the new_path
returns a unit type as outcome in case of success and error in case of failure
open => io.file.this.open[src]
short hand to get the currently
installed open effect
prefix $ => String[Inherited from  Any][src]
convenience prefix operator to create a string from a value.

This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
read(p io.path) => outcome String[src]
read all contents from file
stat(path io.path,resolve bool) => outcome io.file.meta_data[src]
shorthand for accessing and using stats/lstats provided by the stat effect in current environment
in success it will return a meta_data outcome storing stats regarding the file/dir
in case of failure an error will be returned
resolve flag is used to indicate whether to resolve sym links or not
use(R:Any,file_name io.path,m io.file.this.mode.val,code Function (outcome R)) => outcome R[src]
this opens a file with the given mode.
on success it instates effects:

file.this.open,
(io.buffered file.this.file_mutate).reader and
(io.buffered file.this.file_mutate).writer.

These can then be used in `code()`.

usage example:

write(p io.path,a Any) => outcome unit[src]
write `a`.as_string to file `f`

Type Features

type.as_string => String[Inherited from  Type][src]
string representation of this type to be used for debugging.

result has the form "<name>", but this might change in the future

redefines:

type.dynamic_type => Type[Inherited from  Type][src]
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types, so dynamic_type is redefined to just return
Type.type here.

Note: Typechecking is undecidable when 'type' is a type, Mark B. Reinhold, 1989
see: https://dspace.mit.edu/bitstream/handle/1721.1/149366/MIT-LCS-TR-458.pdf?sequence=6

redefines:

type.infix :(T:Any) => bool[Inherited from  Type][src]
Is this type assignable to a type parameter with constraint `T`?

The result of this is a compile-time constant that can be used to specialize
code for a particular type.


it is most useful in conjunction with preconditions or `if` statements as in


or

type.name => String[Inherited from  Type][src]
name of this type, including type parameters, e.g. 'option (list i32)'.
type.prefix $ => String[Inherited from  Type][src]
convenience prefix operator to create a string from a value.

This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.

NYI: Redefinition allows the type feature to be distinguished from its normal counterpart, see #3913

redefines:

type.type_value => Type[Inherited from  Any][src]
Get a type as a value.

This is a feature with the effect equivalent to Fuzion's `expr.type` call tail.
It is recommended to use `expr.type` and not `expr.type_value`.

`type_value` is here to show how this can be implemented and to illustrate the
difference to `dynamic_type`.
0.099dev (GIT hash e2d5298d8107bb5fe79600fdb06a49bc75756344)
last changed: 2026-11-23